home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 November / PCWorld_2007-11_cd.bin / v cisle / dap / dap85.exe / %TEMPCABFULLDIR% / DapLang.cab / dapff.jar / content / dapctxmenu.js < prev    next >
Encoding:
JavaScript  |  2006-10-25  |  3.4 KB  |  149 lines

  1. //***** BEGIN LICENSE BLOCK *****
  2. //* Download Accelerator Plus Integration for Mozilla/Firefox. 
  3. //*
  4. //* The contents of this file may be used under the terms of 
  5. //* Download Accelerator Plus (DAP) End User License Agreement, also 
  6. //* available at http://www.speedbit.com/Legal/DAPLICENSE.ASP ,
  7. //* and is subject to the Speedbit Privacy Policy, also available 
  8. //* at http://www.speedbit.com/Legal/Privacy.ASP. 
  9. //*
  10. //* Copyright (C) 1999-2006 SpeedBit Ltd.
  11. //***** END LICENSE BLOCK *****/
  12. ///////////////////////////////////////////////////////////////////////////////////////
  13. //   context menu handler ( right click Download with DAP 
  14. /////////////////////////////////////////////////////////////////////////////////////////////////
  15.  
  16. function Handler(event, gContextMenu)
  17. {
  18.     DAP_Log("Start Handler right click ");
  19.     try 
  20.     {
  21.         if ( !gContextMenu.onLink ) 
  22.         {
  23.                 DAP_Log("nothing ");
  24.                 return;
  25.         }
  26.         if( !gDAPService )
  27.         {
  28.          DAP_Log("service is null");
  29.          return;
  30.         }
  31.  
  32.         if( !gDAPService._runDAP() )
  33.         {
  34.             DAP_Log("DAP not exist");
  35.             return;
  36.         }
  37.     
  38.       
  39.                 // for FireFox 1.0 
  40.                 var  url = 'getLinkURL' in gContextMenu ? gContextMenu.getLinkURL() : gContextMenu.linkURL(); 
  41.                 var doc = gContextMenu.target.ownerDocument;
  42.                     var href = doc.location.href;
  43.                 
  44.                  var description = getDescriptionFromDocument(doc);
  45.                 var cook = doc.cookie;
  46.     
  47.                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  48.  
  49.                 var obj = gDAPService.getDAPComponent();
  50.                 if( obj )
  51.                     obj.RigthClickMenuDownload(url,href,cook,description,window.navigator.userAgent);
  52.  
  53.     }
  54.     catch(ex) 
  55.     {
  56.             DAP_Log(ex);
  57.     }
  58.  
  59. }
  60. //////////////////////////////////////////////////////////////////////////////////////////////////
  61. //  handler :Download All with DAP 
  62. //////////////////////////////////////////////////////////////////////////////////////////////////
  63. function HandlerAll(event, gContextMenu)
  64. {
  65.     DAP_Log("Start Handler download all with DAP ");
  66.  
  67.   try 
  68.     {
  69.  
  70.       var target = event.originalTarget;
  71.       var doc = gContextMenu.target.ownerDocument;
  72.      if( !doc )
  73.         return;
  74.     
  75.         if( !gDAPService )
  76.         {
  77.          DAP_Log("service is null");
  78.          return;
  79.         }
  80.         if( !gDAPService._runDAP() )
  81.         {
  82.             DAP_Log("DAP not exist");
  83.             return;
  84.         }
  85.  
  86.     
  87.         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  88.         var obj = gDAPService.getDAPComponent();
  89.         if( obj )
  90.             obj.RigthClickMenuDownloadAll(doc,window.navigator.userAgent);
  91.  
  92.     }
  93.     catch(ex) 
  94.     {
  95.         DAP_Log(ex);
  96.      }
  97. }
  98.  
  99.  
  100. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  101. ///  add context menu to right click 
  102. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  103. function DAPMenu()
  104. {
  105.     try
  106.      {
  107.         DAP_Log("DAPMenu");
  108.  
  109.         var cm = gContextMenu;
  110.  
  111.         document.getElementById("dapctxmenu2").hidden = false;
  112.         if (cm.onLink)
  113.             document.getElementById("dapctxmenu1").hidden = false;
  114.         else
  115.             document.getElementById("dapctxmenu1").hidden = true;
  116.     }
  117.     catch(ex)
  118.     {
  119.         DAP_Log(ex);
  120.     }
  121.  
  122. }
  123.  
  124.  
  125. function DAPContextInit()
  126.  {
  127.     try 
  128.     {
  129.  
  130.       DAP_Log("DAPContextInit");
  131.       document.getElementById("contentAreaContextMenu").addEventListener("popupshowing",DAPMenu,false);
  132.  
  133.     } catch (e) {
  134.  
  135.         DAP_Log(e);
  136.  
  137.     }
  138.  
  139.  
  140.  
  141. }
  142.  
  143. // add context menu
  144. window.addEventListener("load",DAPContextInit,false);
  145.  
  146.  
  147.  
  148.  
  149.